﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="andmeprobleemi_teatis", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(AndmeprobleemiTeatis))]
    public class AndmeprobleemiTeatisSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAndmeprobleemiTeatis clazz;
        
        public AndmeprobleemiTeatisSerializer(IAndmeprobleemiTeatis clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.TYHIVASTUS!=null) {
                Writer.WriteStartElement("TYHIVASTUS");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TYHIVASTUS))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("EHITIS");
            if (clazz.EHITIS!=null) {
                global::Xtee.Core.SerializationMetadata metaEHITIS = this.GetMetaData(clazz.EHITIS);
                Writer.WriteTypeAttribute(metaEHITIS.TypeQualifiedName.Namespace, metaEHITIS.TypeQualifiedName.Name);
                metaEHITIS.NewSerializer(clazz.EHITIS).WriteXml(Writer);
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EHITIS");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="TYHIVASTUS") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>andmeprobleemi_teatis>TYHIVASTUS");
                }
                clazz.TYHIVASTUS = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("TYHIVASTUS")).Value;
            }
            if (Reader.LocalName=="EHITIS") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>andmeprobleemi_teatis>EHITIS");
                }
                global::Xtee.Core.SerializationMetadata metaEHITIS = this.GetMetaData<AndmeprobleemiTeatis.IEHITISType>(Reader, ">>andmeprobleemi_teatis>EHITIS", "http://producers.ehr.xtee.riik.ee/producer/ehr");
                clazz.EHITIS = metaEHITIS.NewEntity<AndmeprobleemiTeatis.IEHITISType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("EHITIS");
                    metaEHITIS.NewSerializer(clazz.EHITIS).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>andmeprobleemi_teatis>EHITIS", Reader.LocalName);
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>andmeprobleemi_teatis>EHITIS", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(AndmeprobleemiTeatis.EHITISType))]
        public class EHITISTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected AndmeprobleemiTeatis.IEHITISType clazz;
            
            public EHITISTypeSerializer(AndmeprobleemiTeatis.IEHITISType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                if (clazz.EHRKOOD!=null) {
                    Writer.WriteStartElement("EHR_KOOD");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EHRKOOD))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.NIMETUS!=null) {
                    Writer.WriteStartElement("NIMETUS");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NIMETUS))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.AADRESS!=null) {
                    Writer.WriteStartElement("AADRESS");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AADRESS))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.KASUTUSOTSTARBED!=null) {
                    Writer.WriteStartElement("KASUTUSOTSTARBED");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KASUTUSOTSTARBED))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.OMANDILIIK!=null) {
                    Writer.WriteStartElement("OMANDI_LIIK");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OMANDILIIK))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.EHITISALUNEPIND!=null) {
                    Writer.WriteStartElement("EHITISALUNE_PIND");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EHITISALUNEPIND))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.SULETUDNETOPIND!=null) {
                    Writer.WriteStartElement("SULETUD_NETOPIND");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SULETUDNETOPIND))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.ESMANEKASUTUS!=null) {
                    Writer.WriteStartElement("ESMANE_KASUTUS");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ESMANEKASUTUS))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.BuildingURL!=null) {
                    Writer.WriteStartElement("buildingURL");
                    Writer.WriteTypeAttribute("http://x-tee.riik.ee/xsd/xtee.xsd", "url");
                    Writer.WriteString(clazz.BuildingURL.ToString());
                    Writer.WriteEndElement();
                }
                Writer.WriteStartElement("PIIRANGUD");
                if (clazz.PIIRANGUD!=null) {
                    global::Xtee.Core.SerializationMetadata metaPIIRANGUD = this.GetMetaData(clazz.PIIRANGUD);
                    Writer.WriteTypeAttribute(metaPIIRANGUD.TypeQualifiedName.Namespace, metaPIIRANGUD.TypeQualifiedName.Name);
                    metaPIIRANGUD.NewSerializer(clazz.PIIRANGUD).WriteXml(Writer);
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PIIRANGUD");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("EHITISE_OSAD");
                if (clazz.EHITISEOSAD!=null) {
                    global::Xtee.Core.SerializationMetadata metaEHITISEOSAD = this.GetMetaData(clazz.EHITISEOSAD);
                    Writer.WriteTypeAttribute(metaEHITISEOSAD.TypeQualifiedName.Namespace, metaEHITISEOSAD.TypeQualifiedName.Name);
                    metaEHITISEOSAD.NewSerializer(clazz.EHITISEOSAD).WriteXml(Writer);
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EHITISEOSAD");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("RAJATISE_OSAD");
                if (clazz.RAJATISEOSAD!=null) {
                    global::Xtee.Core.SerializationMetadata metaRAJATISEOSAD = this.GetMetaData(clazz.RAJATISEOSAD);
                    Writer.WriteTypeAttribute(metaRAJATISEOSAD.TypeQualifiedName.Namespace, metaRAJATISEOSAD.TypeQualifiedName.Name);
                    metaRAJATISEOSAD.NewSerializer(clazz.RAJATISEOSAD).WriteXml(Writer);
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : RAJATISEOSAD");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="EHR_KOOD") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>EHR_KOOD");
                    }
                    clazz.EHRKOOD = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EHR_KOOD")).Value;
                }
                if (Reader.LocalName=="NIMETUS") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>NIMETUS");
                    }
                    clazz.NIMETUS = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("NIMETUS")).Value;
                }
                if (Reader.LocalName=="AADRESS") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>AADRESS");
                    }
                    clazz.AADRESS = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AADRESS")).Value;
                }
                if (Reader.LocalName=="KASUTUSOTSTARBED") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>KASUTUSOTSTARBED");
                    }
                    clazz.KASUTUSOTSTARBED = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("KASUTUSOTSTARBED")).Value;
                }
                if (Reader.LocalName=="OMANDI_LIIK") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>OMANDI_LIIK");
                    }
                    clazz.OMANDILIIK = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("OMANDI_LIIK")).Value;
                }
                if (Reader.LocalName=="EHITISALUNE_PIND") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>EHITISALUNE_PIND");
                    }
                    clazz.EHITISALUNEPIND = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EHITISALUNE_PIND")).Value;
                }
                if (Reader.LocalName=="SULETUD_NETOPIND") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>SULETUD_NETOPIND");
                    }
                    clazz.SULETUDNETOPIND = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("SULETUD_NETOPIND")).Value;
                }
                if (Reader.LocalName=="ESMANE_KASUTUS") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>ESMANE_KASUTUS");
                    }
                    clazz.ESMANEKASUTUS = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ESMANE_KASUTUS")).Value;
                }
                if (Reader.LocalName=="buildingURL") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>buildingURL");
                    }
                    clazz.BuildingURL = new global::Xtee.Riik.Ee.Xsd.Xtee.Url(Reader.ReadElementString("buildingURL"));
                }
                if (Reader.LocalName=="PIIRANGUD") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>PIIRANGUD");
                    }
                    global::Xtee.Core.SerializationMetadata metaPIIRANGUD = this.GetMetaData<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>(Reader, "dataType", "http://producers.ehr.xtee.riik.ee/producer/ehr");
                    clazz.PIIRANGUD = metaPIIRANGUD.NewEntity<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("PIIRANGUD");
                        metaPIIRANGUD.NewSerializer(clazz.PIIRANGUD).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>andmeprobleemi_teatis>EHITIS>PIIRANGUD", Reader.LocalName);
                }
                if (Reader.LocalName=="EHITISE_OSAD") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>EHITISE_OSAD");
                    }
                    global::Xtee.Core.SerializationMetadata metaEHITISEOSAD = this.GetMetaData<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>(Reader, "dataType", "http://producers.ehr.xtee.riik.ee/producer/ehr");
                    clazz.EHITISEOSAD = metaEHITISEOSAD.NewEntity<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("EHITISE_OSAD");
                        metaEHITISEOSAD.NewSerializer(clazz.EHITISEOSAD).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>andmeprobleemi_teatis>EHITIS>EHITISE_OSAD", Reader.LocalName);
                }
                if (Reader.LocalName=="RAJATISE_OSAD") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>andmeprobleemi_teatis>EHITIS>RAJATISE_OSAD");
                    }
                    global::Xtee.Core.SerializationMetadata metaRAJATISEOSAD = this.GetMetaData<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>(Reader, "dataType", "http://producers.ehr.xtee.riik.ee/producer/ehr");
                    clazz.RAJATISEOSAD = metaRAJATISEOSAD.NewEntity<global::Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr.IDataType>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("RAJATISE_OSAD");
                        metaRAJATISEOSAD.NewSerializer(clazz.RAJATISEOSAD).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>andmeprobleemi_teatis>EHITIS>RAJATISE_OSAD", Reader.LocalName);
                }
            }
        }
    }
}
